<?php
define('IS_CGI',substr(PHP_SAPI, 0,3)=='cgi' ? 1 : 0 );
defined('APP_NAME') or define('APP_NAME', basename(dirname($_SERVER['SCRIPT_FILENAME'])));
// 当前文件名
if(!defined('_PHP_FILE_')) {
    if(IS_CGI) {
        //CGI/FASTCGI模式下
        $_temp  = explode('.php',$_SERVER['PHP_SELF']);
        define('_PHP_FILE_',    rtrim(str_replace($_SERVER['HTTP_HOST'],'',$_temp[0].'.php'),'/'));
    }else {
        define('_PHP_FILE_',    rtrim($_SERVER['SCRIPT_NAME'],'/'));
    }
}
if(!defined('__ROOT__')) {
    // 网站URL根目录
    if( strtoupper(APP_NAME) == strtoupper(basename(dirname(_PHP_FILE_))) ) {
        $_root = dirname(dirname(_PHP_FILE_));
    }else {
        $_root = dirname(_PHP_FILE_);
    }
    define('__ROOT__',   (($_root=='/' || $_root=='\\')?'':$_root));
}
define('TEMPL_PATH', __ROOT__.'/Templates/');
$root_url= 'http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']);
define('PUBLIC_PATH', $root_url.'/Public/');
?>